package example.lesson03_03;

public class TestRef {
    public static void main(String[] args) {
        Address address = new Address("zs", "xyl");
        Person p1 = new Person(30, "ZhangSan", address); // Ctrl + p
        System.out.println(p1);
    }
}

class Address {
    public String city;
    public String street;
    // Alt + Insert

    public Address(String city, String street) {
        this.city = city;
        this.street = street;
    }
}

class Person {
    public int age;
    public String name;
    // address 缺省值 null
    public Address address;

    Person(int age, String name) {
        this.age = age;
        this.name = name;
    }

    public Person(int age, String name, Address address) {
        this(age, name);
        this.address = address;
    }

    public String toString() {
        return "age:" + age + ", name:" + name +", city:" + address.city + ", street:" + address.street;
    }

}

